package com.xinongbest.mall.config;

import com.xinongbest.mall.filter.AdminFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AdminFilterConfig {

    @Bean
    public AdminFilter adminFilter() {
        return new AdminFilter();
    }

    @Bean(name = "adminFilterConf")
    public FilterRegistrationBean adminFilterConfig() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(adminFilter());
        registrationBean.addUrlPatterns("/admin/category/*");
        registrationBean.addUrlPatterns("/admin/product/*");
        registrationBean.addUrlPatterns("/admin/order/*");
        registrationBean.setName("adminFilterConf");
        return registrationBean;
    }
}
